from django.shortcuts import render

# Create your views here.


def index(request):
    return render(request, "index.html")

def baidu(request):
    return render(request, "baidu.html")

def info(request):
    # 普通变量
    username = '知了课堂'
    # 字典类型
    book = {'name': "水浒传", 'author':'施耐庵'}
    # 列表
    books = [
        {'name': "水浒传", 'author': '施耐庵'},
        {'name': "水浒传", 'author': '施耐庵'}
    ]

    # 4. 对象
    class Person(object):
        def __init__(self, name):
            self.name = name

    context = {
        'username': username,
        'book': book,
        'books': books,
        'person': Person("barry")
    }
    return render(request, "info.html", context=context)

def if_view(request):
    age = 18
    return render(request, "if.html", context={'age':age})

def for_view(request):
    books = [
        {'name': "水浒传", 'author': '施耐庵'},
        {'name': "三国演义", 'author': '罗贯中'},
        {'name': "红楼梦", 'author': '曹雪芹'}
    ]

    persion = {
        'realname' : '知了课堂',
        'age' : 18,
        'height' : 180
    }

    context={
        'books':books,
        'persion':persion
    }
    return render(request, "for.html", context)